{% extends 'layouts/base.html' %}
{% block content %}
<div class="row">
    <div class="col-xs-12">
        <!-- PAGE CONTENT BEGINS -->
        <form action="{{ url('backend/combo/edit', {id:combo.id}) }}" class="form-horizontal" role="form" method="post" enctype="multipart/form-data">

            <div class="form-group{% if errors['name'] is not empty %} has-error{%endif%}">
                <label for="name" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">套餐名称<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input type="text" id="name" placeholder="套餐名称" name="name" class="col-xs-12" value="{{combo.name}}" />
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['name'] is not empty %}{{errors['name']}}{% else %} {%endif%} </div>
            </div>

            <div class="form-group{% if errors['price'] is not empty %} has-error{%endif%}">
                <label for="price" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">价格<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input type="text" id="price" placeholder="价格" name="price" class="col-xs-12" value="{{combo.price}}" />
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['price'] is not empty %}{{errors['price']}}{% else %} {%endif%} </div>
            </div>

            <div class="form-group{% if errors['content'] is not empty %} has-error{%endif%}">
                <label for="content" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">套餐内容<span class="red">*</span></label>
                <div class="wysiwyg-editor" id="content_editor">{{combo.content|raw}}</div>
                <div style="display:none;"><input type="hidden" name="content" id="content" value="{{combo.content|raw}}" /></div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['content'] is not empty %}{{errors['content']}}{% else %} {%endif%} </div>
            </div>
            
            <div class="form-group{% if errors['sort'] is not empty %} has-error{%endif%}">
                <label for="ser_code" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">排序<span class="red">*</span></label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input type="tel" class="smort-input"  id="sort" placeholder="1" name="sort" class="col-xs-12" value="{{combo.sort}}" />
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['sort'] is not empty %}{{errors['sort']}}{% else %} {%endif%} </div>
            </div>
            
            <div class="form-group{% if errors['status'] is not empty %} has-error{%endif%}">
                <label for="status" class="col-xs-12 col-sm-3 col-md-3 control-label no-padding-right">启用</label>
                <div class="col-xs-12 col-sm-4">
                    <span class="block input-icon input-icon-right">
                        <input type="checkbox" id="status_radio" placeholder="状态" name="status_radio" class="ace ace-switch ace-switch-5"{% if combo.status %} checked="checked"{% endif %}" />
                        <span class="lbl"></span>
                        <input type="hidden" name="status" id="status" value="{{combo.status}}"/>
                    </span>
                </div>
                <div class="help-block col-xs-12 col-sm-reset inline"> {% if errors['status'] is not empty %}{{errors['status']}}{% else %} {%endif%} </div>
            </div>

            <div class="clearfix form-actions">
                <div class="col-md-offset-3 col-md-9">
                    <button class="btn btn-info" type="submit">
                        <i class="ace-icon fa fa-check bigger-110"></i>
                        修改
                    </button>

                    &nbsp; &nbsp; &nbsp;
                    <a class="btn" href="javascript:;" onclick="history.back(); ">
                        <i class="ace-icon fa fa-undo bigger-110"></i>
                        重置
                    </a>
                </div>
            </div>

        </form>
    </div><!-- /.col -->
</div><!-- /.row -->
{% endblock %}
{% block script %}

<script type="text/javascript">
    $(document).ready(function(){

        $(".ace-switch").each(function () {
            var aceswitch = this;

            aceswitch.addEventListener("click", function(){
                id = this.id.replace("_radio", "");
                if(this.checked){
                    $("#"+id).val('1');
                } else {
                    $("#"+id).val('0');
                }
                });
        });
        
        $('#content_editor').ace_wysiwyg({
            'wysiwyg': {
                 uploadScript: "{{ url('backend/upload/upload', {'dir':'combo'}) }}",
                 uploadOptions: {
                     post_id: '10',
                     revision_id: '3'
                 }
             }
         });
         $('#content_editor').focusout(function() {
             $('#content').val($('#content_editor').html());
         });
    });
</script>
{% endblock %}
